Skip to content

Add --in-git-diff convenience option - #628

Open
ychampion wants to merge 1 commit into
sourcefrog:mainfrom
ychampion:fix/in-git-diff-245
Open

Add --in-git-diff convenience option#628
ychampion wants to merge 1 commit into
sourcefrog:mainfrom
ychampion:fix/in-git-diff-245

Conversation

@ychampion

Copy link
Copy Markdown

Summary

  • add --in-git-diff REVISION as a convenience wrapper around git diff
  • reuse the existing diff filter and cover nested workspaces and invalid revisions

Why

This avoids writing a temporary patch file when testing changes from a branch or pull request.

Closes #245.

Validation

  • cargo test --locked diff -- --nocapture
  • cargo clippy --all-targets --all-features --locked -- -D warnings
  • cargo fmt --all -- --check
  • cargo build --release --locked
  • cargo machete

Add the maintainer-requested Git revision adapter while reusing the existing unified-diff filter. Keep explicit patch-file input unchanged and cover nested workspaces plus invalid revisions.

Constraint: Use the Git CLI requested in sourcefrog#245 without adding a dependency.
Rejected: git2-rs | Unnecessary build weight for a single diff invocation.
Confidence: high
Scope-risk: narrow
Directive: Keep --in-diff and --in-git-diff mutually exclusive.
Tested: Focused diff tests; strict all-target/all-feature Clippy; 429/431 all-feature nextest cases; release build and nested-workspace smoke; rustfmt; cargo-machete; diff checks.
Not-tested: mdBook linkcheck and typos binaries are unavailable locally; two permission-denied tests fail as root identically on upstream.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new CLI filter option, --in-git-diff REVISION, to let cargo-mutants compute a diff by invoking git diff directly and then reuse the existing diff-based mutant filtering logic (including behavior for nested workspaces and invalid revisions).

Changes:

  • Add --in-git-diff REVISION CLI option and wire it into mutant filtering flow.
  • Implement diff_filter_git() to run git diff and feed its output into the existing diff filter.
  • Add tests plus user-facing documentation updates (book + NEWS).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/main.rs Adds integration tests for filtering via git diff, including nested workspace and invalid revision handling.
src/main.rs Introduces the --in-git-diff argument and applies it in the main filtering pipeline.
src/in_diff.rs Adds diff_filter_git() and a new DiffFilterError::Git error variant for git invocation failures.
NEWS.md Documents the new --in-git-diff option in Unreleased notes.
book/src/in-diff.md Updates the user guide to describe --in-git-diff and its interaction with --in-diff.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/in_diff.rs
workspace_root: &Utf8Path,
revision: &str,
) -> Result<Vec<Mutant>, DiffFilterError> {
let output = Command::new("git")
Comment thread tests/main.rs
Comment on lines +2042 to +2044
&["add", "."],
&["commit", "--quiet", "--message", "baseline"],
] {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--in-git-diff convenience option

2 participants